package com.tiantian.novel.model;

import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * chapter info
 *
 * @author wangkai
 * @since 2020/12/17.
 */
@Data
public class ChapterInfo implements Serializable {
    private Integer id;
    private String url;
    private String title;
    private String content;
    private boolean finished;

    public ChapterInfo() {
    }

    public ChapterInfo(int id) {
        this(id, "", "");
    }

    public ChapterInfo(int id, String url, String title) {
        this.id = id;
        this.url = url;
        this.title = title;
        this.finished = false;
    }

    public ChapterInfo setContent(String content) {
        this.content = content;
        this.finished = true;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        return this.title.equals(((ChapterInfo) o).getTitle());
    }

    @Override
    public int hashCode() {
        return Objects.hash(title);
    }
}
